package it.dgtest.client.crud;

import it.dgtest.client.datasource.ComuniDataSource;
import it.dgtest.shared.Comune;

import com.google.gwt.core.client.GWT;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.uibinder.client.UiHandler;
import com.google.gwt.user.client.ui.Widget;
import com.oa.gform.client.GFormBinder;
import com.oa.gform.client.ui.GForm;
import com.oa.gform.client.ui.GRepeater;
import com.oa.gform.client.ui.event.GRepeaterItemClickEvent;
/***
 * Autogenerato con DecGen.
 * @author Marco
 *
 */
public class ListComune extends GForm {
	private static ListComuneUiBinder uiBinder = GWT.create(ListComuneUiBinder.class);
	interface ListComuneUiBinder extends UiBinder<Widget, ListComune> {}

	private static ListComuneGFormBinder gFormBinder = GWT.create(ListComuneGFormBinder.class);
	interface ListComuneGFormBinder extends GFormBinder<Widget, ListComune> {}

	@UiField
	GRepeater<Comune> repeaterComuni;
	
	/***
	 * Costruttore della form
	 */
	public ListComune() {
		// Inizializza il tamplate ui.xml
		initWidget(uiBinder.createAndBindUi(this));
		// Inizializza il GFormBinder
		gFormBinder.createAndBindGForm(this);
		
		// Carico il datasource direttamente da codice
		ComuniDataSource comuniDataSource = new ComuniDataSource();
		repeaterComuni.setGDatasource(comuniDataSource);
		repeaterComuni.render(); 
	}
	
	@UiHandler("repeaterComuni")
	void onRepeaterComuniAction(GRepeaterItemClickEvent<?> e) {
		System.out.println(e.toString());
	}

			
}
